﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace jQuery.Validation.DataAnnotations
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public sealed class DateAttribute : ValidationAttribute
    {
        public DateAttribute()
        {
        }

        public override bool IsValid(object value)
        {
            if (value == null)
                return true;

            if (value is DateTime)
            {
                return true;
            }

            if (value is string)
            {
                DateTime date;
                return DateTime.TryParse(value.ToString(), out date);
            }

            return false;
            
        }
    }
}
